home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / monitors / restracker / techinfo.doc < prev   
Encoding:
Text File  |  1996-07-16  |  2.4 KB  |  51 lines

  1. techinfo.doc
  2.  
  3. Here's some technical information for those of you who want to know how the
  4. resource tracking works.
  5.  
  6. The first thing "rt" does is to allocate space for a semaphore and a
  7. minimal list header. The semaphore is initialized and added to the public
  8. system semaphore list where other programs can find and use it to access
  9. the list.
  10. Then the config file is parsed and a patch function called for every valid
  11. library entry. This function does the following:
  12. - allocate a minimal node, a special ResourceList structure and space for
  13.   two functions to be patched into the allocation/deallocation functions
  14.   respectively.
  15. - initialize the ResourceList
  16. - initialize a memory pool for use by the patch functions
  17. - copy the two patch routines in place
  18. - modify the patch code to make it use the correct registers for
  19.   (de-)allocation of resources. Yea, I know self-modifying code is a no-no
  20.   but for performance reasons there was no better way to do it. At least I
  21.   finally
  22. - clear the CPU caches!
  23.  
  24. The LVOs of the patched OS functions, the library name and some other info
  25. from the config file are stored in the ResourceList which is then added to
  26. the main list by its node part after the actual patching took place.
  27.  
  28. Every time a resource allocation is requested, the patch allocates a node
  29. structure with space for a resource pointer and a task pointer using its
  30. private memory pool. This node is then added to the ResourceList. On
  31. resource deallocation the ResourceList is searched (newest entries first to
  32. speed things up) for the given resource. If the resource was found, the
  33. node is removed from the list and its memory given back to the pool.
  34.  
  35. To give resources allocated by a crashed task back to the system, the
  36. following steps are needed:
  37. - find the crashed task's address
  38. - find and gain access to the public sempahore called "ResourceTracker"
  39. - get the MinList structure directly attached to the sempahore
  40. - while there are nodes left in this MinList do
  41.   - get the ResourceList structure directly attached to any node
  42.   - while there are nodes left in this ResourceList do
  43.     - compare every node's task field with the crashed task's address
  44.     - if they are equal
  45.       - get the LibName and FreeOffset fields from the current ResourceList
  46.       - open the library and pass the current node's resource field to the
  47.         deallocation function
  48.     - proceed to next ResourceNode
  49.   - proceed to next node
  50. - release the main list semaphore
  51.